# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=xlsxwriter
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}"
         "${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=0.9.6
pkgrel=1
pkgdesc="A Python module for creating Excel XLSL files (mingw-w64)"
url="https://github.com/jmcnamara/XlsxWriter"
arch=('any')
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python3-pytest"
              "${MINGW_PACKAGE_PREFIX}-python2-pytest")
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/jmcnamara/XlsxWriter/archive/RELEASE_${pkgver}.tar.gz")
sha256sums=('98b8c06e9e3ea5ca0d7f142c460753d80ebf79e17104163f5c59ff5870d784ce')

prepare() {
  cp -a XlsxWriter-RELEASE_${pkgver} XlsxWriter-RELEASE_${pkgver}-py2
}

build() {
  cd ${srcdir}/XlsxWriter-RELEASE_${pkgver}
  python3 setup.py build

  cd ${srcdir}/XlsxWriter-RELEASE_${pkgver}-py2
  python2 setup.py build
}

#check() {
#  cd ${srcdir}/XlsxWriter-RELEASE_${pkgver}
#  py.test-3.5.exe
#
#  cd ${srcdir}/XlsxWriter-RELEASE_${pkgver}-py2
#  py.test-2.7
#}


package_python3-xlsxwriter() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd ${srcdir}/XlsxWriter-RELEASE_${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -Dm644 LICENSE.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE
  
  mv ${pkgdir}${MINGW_PREFIX}/bin/vba_extract{,-py3}.py
}

package_python2-xlsxwriter() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd ${srcdir}/XlsxWriter-RELEASE_${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -Dm644 LICENSE.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE
}

package_mingw-w64-i686-python2-xlsxwriter() {
  package_python2-xlsxwriter
}

package_mingw-w64-i686-python3-xlsxwriter() {
  package_python3-xlsxwriter
}

package_mingw-w64-x86_64-python2-xlsxwriter() {
  package_python2-xlsxwriter
}

package_mingw-w64-x86_64-python3-xlsxwriter() {
  package_python3-xlsxwriter
}

# vim:set ts=2 sw=2 et:
